package com.ruoyi.web.controller.business;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.bussiness.domain.SysBusinessCheckList;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.bussiness.domain.SysBusinessDynamic;
import com.ruoyi.bussiness.service.ISysBusinessDynamicService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 业务-动态Controller
 *
 * @author ruoyi
 * @date 2023-12-12
 */
@RestController
@RequestMapping("/bussiness/dynamic")
public class SysBusinessDynamicController extends BaseController
{
    @Autowired
    private ISysBusinessDynamicService sysBusinessDynamicService;

    /**
     * 查询业务-动态列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:dynamic:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysBusinessDynamic sysBusinessDynamic)
    {
        startPage();
        List<SysBusinessDynamic> list = sysBusinessDynamicService.selectSysBusinessDynamicList(sysBusinessDynamic);
        return getDataTable(list);
    }

    /**
     * 导出业务-动态列表
     */
    @PreAuthorize("@ss.hasPermi('bussiness:dynamic:export')")
    @Log(title = "业务-动态", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SysBusinessDynamic sysBusinessDynamic)
    {
        List<SysBusinessDynamic> list = sysBusinessDynamicService.selectSysBusinessDynamicList(sysBusinessDynamic);
        ExcelUtil<SysBusinessDynamic> util = new ExcelUtil<SysBusinessDynamic>(SysBusinessDynamic.class);
        util.exportExcel(response, list, "业务-动态数据");
    }

    /**
     * 获取业务-动态详细信息
     */
    @PreAuthorize("@ss.hasPermi('bussiness:dynamic:query')")
    @GetMapping(value = "/{dynamicId}")
    public AjaxResult getInfo(@PathVariable("dynamicId") Long dynamicId)
    {
        return success(sysBusinessDynamicService.selectSysBusinessDynamicByDynamicId(dynamicId));
    }

    /**
     * 新增业务-动态
     */
    @PreAuthorize("@ss.hasPermi('bussiness:dynamic:add')")
    @Log(title = "业务-动态", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysBusinessDynamic sysBusinessDynamic)
    {
        return toAjax(sysBusinessDynamicService.insertSysBusinessDynamic(sysBusinessDynamic));
    }

    /**
     * 修改业务-动态
     */
    @PreAuthorize("@ss.hasPermi('bussiness:dynamic:edit')")
    @Log(title = "业务-动态", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysBusinessDynamic sysBusinessDynamic)
    {
        return toAjax(sysBusinessDynamicService.updateSysBusinessDynamic(sysBusinessDynamic));
    }

    @PutMapping("/moveUpOrDown")
    public AjaxResult moveUpOrDown(@RequestBody SysBusinessDynamic entity)
    {
        return sysBusinessDynamicService.moveUpOrDown(entity);
    }

    /**
     * 删除业务-动态
     */
    @PreAuthorize("@ss.hasPermi('bussiness:dynamic:remove')")
    @Log(title = "业务-动态", businessType = BusinessType.DELETE)
	@DeleteMapping("/{dynamicIds}")
    public AjaxResult remove(@PathVariable Long[] dynamicIds)
    {
        return toAjax(sysBusinessDynamicService.deleteSysBusinessDynamicByDynamicIds(dynamicIds));
    }

    @PostMapping("/back/{dynamicIds}")
    public AjaxResult back(@PathVariable Long[] dynamicIds)
    {
        return toAjax(sysBusinessDynamicService.backSysBusinessDynamicByDynamicIds(dynamicIds));
    }
}
